package setting

// Service 系统服务配置
type Service struct {
	Account Account `json:"account" label:"账户" help:"账户相关配置"`
	Sms     Sms     `json:"sms" label:"短信验证码" condSupport:"false" help:"短信验证码防刷相关配置，不支持分区配置"`
}

type Account struct {
	DefaultAvatar DefaultAvatar     `json:"defaultAvatar" label:"默认头像" help:"默认头像"`
	LoginLimit    AccountLoginLimit `json:"loginLimit" label:"暴力登录限制" help:"暴力登录限制，在登陆失败时间范围内，超过登陆失败次数，将限制设备登陆一段时间" default:"" validate:"required"` // 暴力登录限制
}

type DefaultAvatar struct {
	Male   string `json:"male" label:"男(未知)" help:"默认男性和未知性别人的头像" validate:"required,url"`
	Female string `json:"female" label:"女" help:"默认女性的头像" validate:"required,url"`
}

type AccountLoginLimit struct {
	Switch bool `json:"switch" label:"限制开关" help:"限制开关，开启后，在登陆失败时间范围内，超过登陆失败次数，将限制设备登陆一段时间" default:"false" validate:"omitempty,gt=0"`
	Time   int  `json:"time" label:"时间范围(m)" help:"登陆失败时间范围内（分钟）" default:"20" validate:"omitempty,gt=0"`
	Times  int  `json:"times" label:"错误次数" help:"登陆失败次数" default:"" validate:"omitempty,gt=0"`
	Limit  int  `json:"limit" label:"限制时间(m)" help:"限制时间（分钟）" default:"" validate:"omitempty,gt=0"`
}

type Sms struct {
	Interval       int64 `json:"interval" label:"发送间隔(s)" help:"短信发送间隔（秒）" default:"60" validate:"omitempty,gt=0"`
	CaptchaExpired int64 `json:"captchaExpired" label:"验证码过期时间(s)" help:"验证码过期时间（秒）" default:"300" validate:"omitempty,gt=0"`
	DayIpLimit     int   `json:"dayIpLimit" label:"日IP限制" help:"每天每个IP的验证码发送次数" default:"5" validate:"omitempty,gt=0"`
	DayMacLimit    int   `json:"dayMacLimit" label:"日设备限制" help:"每天每个设备的验证码发送次数" default:"8" validate:"omitempty,gt=0"`
	DayPhoneLimit  int   `json:"dayPhoneLimit" label:"日号码限制" help:"每天每个号码的验证码发送次数" default:"8" validate:"omitempty,gt=0"`
}
